package com.wind.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author: i promise
 * @date: 2018/8/8 20:53
 */
@Configuration
@ConfigurationProperties(prefix="root-config")
public class PropConfig {

    @Bean(name="PropConfig",initMethod="initSAA")
    public PropConfig propConfig() {
        return new PropConfig();
    }


    private String orbitTimeInterval;

    private String location;

    private String ORB_EPHlocation;

    private String predictlocation;

    private String sun_moonlocation;

    private String TLE_EPHlocation;

    public List<String> SAA = new ArrayList<>();

    public static List<String> SaaLonList = new ArrayList<>();

    public static List<String> SaaLatList = new ArrayList<>();

    private static String  maxSaaLon ;

    private static String  minSaaLon;

    public String getOrbitTimeInterval() {
        return orbitTimeInterval;
    }

    public void setOrbitTimeInterval(String orbitTimeInterval) {
        this.orbitTimeInterval = orbitTimeInterval;
    }

    private static String  maxSaaLat;

    private static String  minSaaLat;




    public List<String> getSAA() {
        return SAA;
    }


    public void initSAA() {
        List<String> tempSaaLonList = new ArrayList<>();

        List<String> tempSaaLatList = new ArrayList<>();
        for (String tempSAA:SAA)
        {
            String[] templonlat = tempSAA.split(",");
            SaaLonList.add(templonlat[0]);
            SaaLatList.add(templonlat[1]);
            tempSaaLonList.add(templonlat[0]);
            tempSaaLatList.add(templonlat[1]);
        }



        Collections.sort(tempSaaLonList,new SortByStringDouble());
        Collections.sort(tempSaaLatList,new SortByStringDouble());


        minSaaLon = tempSaaLonList.get(0);

        minSaaLat = tempSaaLatList.get(0);

        maxSaaLon = tempSaaLonList.get(tempSaaLonList.size()-1);
        maxSaaLat = tempSaaLatList.get(tempSaaLatList.size()-1);


    }
    public List<String> getSaaLonList() {

        return SaaLonList;
    }

    public List<String> getSaaLatList() {

        return SaaLatList;
    }
    public String getMaxSaaLon() {

        return maxSaaLon;
    }

    public String getMinSaaLon() {
        return minSaaLon;
    }

    public String getMaxSaaLat() {
        return maxSaaLat;
    }

    public String getMinSaaLat() {
        return minSaaLat;
    }





    public void setSAA(List<String> SAA) {
        this.SAA = SAA;
    }

    public String getORB_EPHlocation() {
        return ORB_EPHlocation;
    }

    public void setORB_EPHlocation(String ORB_EPHlocation) {
        this.ORB_EPHlocation = ORB_EPHlocation;
    }

    public String getPredictlocation() {
        return predictlocation;
    }

    public void setPredictlocation(String predictlocation) {
        this.predictlocation = predictlocation;
    }

    public String getSun_moonlocation() {
        return sun_moonlocation;
    }

    public void setSun_moonlocation(String sun_moonlocation) {
        this.sun_moonlocation = sun_moonlocation;
    }

    public String getTLE_EPHlocation() {
        return TLE_EPHlocation;
    }

    public void setTLE_EPHlocation(String TLE_EPHlocation) {
        this.TLE_EPHlocation = TLE_EPHlocation;
    }

    public String getXYZ_EPHlocation() {
        return XYZ_EPHlocation;
    }

    public void setXYZ_EPHlocation(String XYZ_EPHlocation) {
        this.XYZ_EPHlocation = XYZ_EPHlocation;
    }

    public String getXyzkeptranslocation() {
        return xyzkeptranslocation;
    }

    public void setXyzkeptranslocation(String xyzkeptranslocation) {
        this.xyzkeptranslocation = xyzkeptranslocation;
    }

    private String XYZ_EPHlocation;

    private String xyzkeptranslocation;


    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }
}
